<?php

use think\migration\Migrator;
use Phinx\Db\Adapter\MysqlAdapter;

class CreateUserTable extends Migrator
{

    /**
     * Migrate Up.
     */
    public function up()
    {
        $this->table('user', ['comment' => '用户表', 'engine' => 'InnoDB', 'collation' => 'utf8_general_ci', 'id' => 'id', 'primary_key' => ['id']])
            ->addColumn('user_name', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '用户名称'])
            ->addColumn('user_code', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '用户登录名'])
            ->addColumn('user_pwd', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '用户密码'])
            ->addColumn('email', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '用户邮箱'])
            ->addColumn('sex', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '性别'])
            ->addColumn('register_ip', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '创建ip'])
            ->addColumn('land_time', 'datetime', ['null' => true,'signed' => true,'comment' => '登录时间'])
            ->addColumn('land_ip', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '登录ip'])
            ->addColumn('land_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '登录状态'])
            ->addColumn('is_enable', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '是否启用'])
            ->addColumn('only_no', 'string', ['limit' => 300,'null' => true,'signed' => true,'comment' => '登录唯一标识'])
            ->addColumn('open_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '第三方id'])
            ->addTimestamps()           
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('user');
    }
}
